package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrdersMapper {
    void insert(Orders orders);
    Page<Orders> history(OrdersPageQueryDTO ordersPageQueryDTO);

    Orders getById(Long id);

    void update(Orders orders1);


    //////////////////////////////////////////////

    /**
     * 订单搜索
     * @param ordersPageQueryDTO
     * @return
     */
    Page<Orders> page(OrdersPageQueryDTO ordersPageQueryDTO);

    Integer statistics(Integer toBeConfirmed);

    Page<OrderVO> list(OrdersPageQueryDTO ordersPageQueryDTO);

    @Select("select * from orders where number = #{orderNumber} and user_id= #{userId}")
    Orders getByNumberAndUserId(String outTradeNo, Long userId);

    List<Long> getIdsByStatusAndTime(@Param("status") Integer pendingPayment, @Param("orderTime")LocalDateTime dateTime);


}
